package com.bookcode.service;

import com.bookcode.dao.UserRepository;
import com.bookcode.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    UserRepository userRepository;



    public User findUserById(Long id){
        return userRepository.findById(id).get();
    }

    public void save(User user){
        userRepository.save(user);
    }
    public User findUserByName(String username){
        return userRepository.findUserByName(username);
    }

    public List<User> findAll(){
        return userRepository.findAll();
    }
}
